package com.itheima.task;

import cn.jpush.api.JPushClient;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.Notification;

/**
 * demo测试 需要自己在官网申请sdkdemo
 * @author zhangyan
 * @date 2021/4/7 21:33
 */
public class JpushDemo {

    public static void main(String[] args) throws Exception {
        //构建推送客户端
        JPushClient jPushClient = new JPushClient("c7e8e44b63d95ec9bc94f965", "55de5d60083f940ffdd34c32");

        //组装推送对象
        PushPayload payload = PushPayload.newBuilder()
                .setPlatform(Platform.all()) //全平台
                .setAudience(Audience.registrationId("120c83f7608109fc2a9")) //推送目标用户,alias:设备别名 tag:设备标签 registrationId:注册ID
                .setNotification(Notification.newBuilder().addPlatformNotification(
                        AndroidNotification.newBuilder().setTitle("申请加入").setAlert("xxx 申请加入企业,请审批").build()).build())
                .build();

        //推送消息
        jPushClient.sendPush(payload);

    }
}

